<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>会员中心 --<Zml:title /></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="__PUBLIC__/css/pintuer.css">
<script src="__PUBLIC__/js/jquery-1.8.3.min.js"></script>
<script src="__PUBLIC__/js/pintuer.js"></script>
<script src="__PUBLIC__/js/respond.js"></script>
<script src="__LIB__/layer/layer.js"></script>
</head>
<body style="background:#e7e8eb">
<include file="Home@default/Public/header" />
<include file="./header" />
<div class="x12 padding border-bottom height-big">
	<h5>基本信息</h5>	
</div>
<div class="clearfix"></div>
<div class="padding  x12">
	<div class="border x12">
	<div class="bg padding ">用户基本信息</div>	
		<div class="height-large padding border-bottom x12">
			<span class="text-gray x2">昵称</span>
			<span class="x9">
			<span  onclick="edit('name','{$user.name}',this)">
			<if condition="$user['name']">
				{$user.name}
			<else />
				未知
			</if>
			<i class="text-gray">(点击修改)</i>
			</span>
			</span>
			
		</div>
		<div class="height-large padding border-bottom x12">
			<span class="text-gray x2">手机号</span>
			<span class="x9" id="domain">{$user.phone}</span>
			<a href="__MODULE__/Info/edit_phone" class="text-blue" >修改</a>
		</div>
		<div class="height-large padding border-bottom x12">
			<span class="text-gray x2">头像</span>
			<span class="x9"><img src="<if condition="$user['header']">{:cut_image($user['header'],'90','90')}<else />__IMG__user-logo.jpg</if>" class="header" height="90" /></span>
			<a class="input-file text-blue" href="javascript:void(0);">	
				上传
				<input size="100" type="file" id='fileupload' name='upfile' />
			</a>
		</div>
		<div class="height-large padding border-bottom x12">
			<span class="text-gray x2">年龄</span>
			<span class="x9" id="title">
			<span  onclick="edit('age','{$user.age}',this)">
			<if condition="$user['age']">
				{$user.age}
			<else />
				未知
			</if>
			<i class="text-gray">(点击修改)</i>
			</span>
			</span>
		
		</div>
		<div class="height-large padding border-bottom x12">
			<span class="text-gray x2">性别</span>
			<span class="x9" >
				<label> <input type="radio" onclick="savesex('0',this)" name="sex" value="0" <if condition="$user['sex'] eq '0'">checked</if> /> 未知 </label>
				<label> <input type="radio" onclick="savesex('1',this)" name="sex" value="0" <if condition="$user['sex'] eq '1'">checked</if> /> 男 </label>
				<label> <input type="radio" onclick="savesex('2',this)" name="sex" value="0" <if condition="$user['sex'] eq '2'">checked</if> /> 女 </label>
			</span>
		</div>
		<div class="height-large padding border-bottom x12">
			<span class="text-gray x2">住所</span>
			<span class="x9" id="desc">
				<select name="province" class="input input-auto"  id="province" onchange="loadRegion('province',2,'city','__MODULE__/Region/index');">
				<option value="" >省份/直辖市</option>
				<volist name="prove" id="vo">
					<option value="{$vo.id}" <if condition="$user['province'] eq $vo['id']">selected</if> >{$vo.name}</option>
				</volist>
				</select>
				<select name="city" class="input input-auto " id="city" data-validate="required:请选择城市"  onchange="loadRegion('city',3,'area','__MODULE__/Region/index');">
			
					<option value="{$user.city}">{$user.cityname}</option>
				</select>
				<select name="area" class="input input-auto" data-validate="required:请选择镇区" id="area">			
						<option value="{$user.area}">{$user.areaname}</option>
				</select>		
				<input type="text" class="input input-auto" value="{$user.address}" id="address" name="address" />		
			</span>
			<a href="###" class="text-blue"  onclick="saveaddress(this)">保存修改</a>
		</div>
		<div class="height-large padding   x12">
			<span class="text-gray x2">注册时间</span>
			<span class="x9" ><span class="text-gray">{:date('Y-m-d',$user['create_time'])} </span></span>
		</div>
		
	</div>
</div>
</div>
</div>
</div>
<div class="clearfix"></div>
<include file="Home@default/Public/foot" />
<script src="__PUBLIC__/js/form.js"></script>
<script src="__PUBLIC__/lib/region.js"></script>
<script>
function saveaddress(d){
	var prov=$("#province").val();
	var city=$("#city").val();
	var area=$("#area").val();
	var address=$("#address").val();
	$.post('__MODULE__/Info/edit',{province:prov,city:city,area:area,address:address},function(e){
		$("#address").val(address);
		layer.msg('更新成功', {shift: 2});
	})
}
function edit(name,id,d){
	var html='<input type="text" name="'+name+'" class="input input-auto" size="20" value='+id+' /> <button class="button" type="button" onclick="save(\''+name+'\',this)">保存</button>';
	$(d).parent().html(html);
}
function save(name,d,value){
	var v=$(d).siblings('input[name="'+name+'"]').val();
	if(name=='name'){
		$.post('__MODULE__/Info/edit',{name:v},function(e){
			if(e.status=1){
				$(d).parent().text(v);
				layer.msg('更新成功', {shift: 2});
			}else{
				$(d).parent().text(v);
				layer.msg('更新失败', {shift: 2});
			}
		})
	}else if(name=='age'){
		$.post('__MODULE__/Info/edit',{age:v},function(e){
			if(e.status=1){
				$(d).parent().text(v);
				layer.msg('更新成功', {shift: 2});
			}else{
				$(d).parent().text(v);
				layer.msg('更新失败', {shift: 2});
			}
		})
	}else if(name=='header'){
		$.post('__MODULE__/Info/edit',{header:value},function(e){
			if(e.status=1){
				layer.msg('更新成功', {shift: 2});
			}else{
				layer.msg('更新失败', {shift: 2});
			}
		})
	}
}
function savesex(v,d){
	$.post('__MODULE__/Info/edit',{sex:v},function(e){
			if(e.status=1){
				layer.msg('更新成功', {shift: 2});
			}else{
				layer.msg('更新失败', {shift: 2});
			}
	})
}

$(function () {
	var bar = $('.bar');
	var percent = $('.jindu');
	var showimg = $('.content');
	var progress = $(".jindu");
	var files = $(".files");
	var btn = $(".btn span");
	$("#fileupload").wrap("<form id='myupload' action='__ROOT__/Admin/Upload' method='post' enctype='multipart/form-data'></form>");
    $("#fileupload").change(function(){
		$("#myupload").ajaxSubmit({
			dataType:  'json',
			beforeSend: function() {
        		var index = layer.load(1, {
					shade: [0.1,'#fff'] //0.1透明度的白色背景
				});
    		},
			success: function(data) {
				if(data.status==0){
					layer.open({
						content:data.info,
						btn:['好的'],
						yes:function(){
							layer.closeAll()
						}
					})
				}else{
					var img = data.url;
					$(".header").attr('src',img);
					save('header','header',''+img+'');
					layer.closeAll()
					
				}
			}
		});
	});
	
});	

</script>
</body>
</html>